package edu.gdin.ecommerce.service.impl;

import java.util.List;

import javax.annotation.Resource;

import org.springframework.stereotype.Service;

import edu.gdin.ecommerce.dao.FuncDAO;
import edu.gdin.ecommerce.model.Func;
import edu.gdin.ecommerce.service.IFuncService;

@Service("funcService")
public class FuncService implements IFuncService {

	private FuncDAO funcDAO;

	public FuncDAO getFuncDAO() {
		return funcDAO;
	}
	@Resource
	public void setFuncDAO(FuncDAO funcDAO) {
		this.funcDAO = funcDAO;
	}
	
	
	/**
	 * 获取所有Func
	 * @return
	 */
	@SuppressWarnings("unchecked")
	public List<Func> getAllFuncs() {
		return (List<Func>) this.funcDAO.list(Func.class);
	}
	
	/**
	 * 判断是否存在同名权限
	 * @param func
	 * @return
	 */
	public boolean isExist(Func func) {
		return this.funcDAO.isExist(Func.class, "name", func.getName());
	}
	
	/**
	 * 添加Func
	 * @param func
	 */
	public void addFunc(Func func) {
		this.funcDAO.insert(func);
	}
	
}
